You are here: Symbol Reference > Dew Namespace > Dew.Signal Namespace > Dew.Signal.Units Namespace > Classes > SignalUtils Class > SignalUtils Methods > SignalUtils.IirInitBQ Method
Dew Signal for .NET
ContentsIndexHome
PreviousUpNext
SignalUtils.IirInitBQ Method

Initialize an IIR filter with second order sections.

Syntax
C#
Visual Basic
public static void IirInitBQ([In] TVec sos, ref TIirState IIRState, bool ComplexData);

Initialize an IIR filter by initializing the IirState variable. Set ComplexData to True, if the data stream to be filtered will be complex. The Sos (real) vector variable contains second order sections as produced by the ZeroPoleToSOS function: 

(B00, B10, B20, A00, A10, A20), (B01, B11, B21, A01, A11, A21), (.... ),... 

B - numerator sections array A - denumarator sections array 

Using second order sections to compute an IIR filter results in higher numerical accuracy and greater filter stability at a slightly higher cost on performance.

Lowpass filter a sine signal with Chebyshev type I filter. Sampling frequency is 2Hz, cutoff frequency is 0.6 Hz. Passband ripple is 0.2 dB and filter order is 6.

using Dew.Math; using Dew.Math.Editors; using Dew.Math.Units; using Dew.Signal; using Dew.Signal.Units; using Dew.Math.Tee; using Dew.Signal.Tee; private void button1_Click(object sender, EventArgs e) { Vector b = new Vector(0); Vector c = new Vector(0); Vector sos = new Vector(0); Vector Response1 = new Vector(0); Vector Response2 = new Vector(0); TIirState state = new TIirState(); int n; int i; SignalUtils.Tone(b,300,6.0/300,0,1,false); // Alternative: try gaussian noise // b = MtxExpr.RandGauss(300); IIRFilters.ChebyshevIFilter(6,0.2,new double[1] {0.6}, TFilterType.ftLowpass,false,sos,TIirFrequencyTransform.ftStateSpaceAnalog); SignalUtils.IirInit(sos,ref state,false); try { c.Copy(b); //backup data SignalUtils.IirFilter(c,state); //apply filter to the data } finally { SignalUtils.IirFree(ref state); //free structure, if you dont require this IIR filter anymore } MtxVecTee.DrawIt(new TVec[2] {b,c}, new string[2] {"Original signal","Filtered signal"},"Time signals", false); SignalUtils.FrequencyResponse(c, null, Response1, 1, true, TSignalWindowType.wtHanning, 0); SignalUtils.FrequencyResponse(b, null, Response2, 1, true, TSignalWindowType.wtHanning, 0); MtxVecTee.DrawIt(new TVec[2] {Response1,Response2}, new string[2] {"Spectrum: original signal","Spectrum: filtered signal"}, "Frequency spectrum", false); }
Copyright (c) 1999-2024 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!